package com.hmall.conf;

import com.hmall.interceptor.TokenUserInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Slf4j
@Configuration // 被该注解修饰的类一般称为配置类
public class MvcConfig implements WebMvcConfigurer {

    @Autowired
    private TokenUserInterceptor tokenUserInterceptor;

    /**
     * 注册拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        log.info("注册拦截器。。。。");
        registry.addInterceptor(tokenUserInterceptor).addPathPatterns("/**");

    }
}
